< previous page page_335 next page >

Page 335
    lngRecords = db.RecordsAffected
    '
    ' show results
    MsgBox CStr(lngRecords), vbInformation, "Deleted Records"
    '
    ' clean up
    db.Close
    ws.Close
    Set db = Nothing
    Set ws = Nothing
    '
End Sub
The code in Listing 9.12 opens a database and performs an SQL action query that deletes records from a table. The routine displays the RecordsAffected property to show you how many records were deleted, and then it closes the database.
Save and run the project. Click Execute and compare your on-screen results with the screen in Figure 9.11.
0335-01.jpg
Figure 9.11.
The results of the 
Execute method.
Using the CreateProperty Method
Visual Basic lets you create user-defined properties (UDPs) for most data-access objects. These UDPs get stored with the database and can be read and updated by your Visual Basic program. In this example, you use the CreateProperty method to add a UDP to a database.
warning.gif
The capability to create and store UDPs is only available when you use the Microsoft Jet version 3.0 or later database format. If you are not using Microsoft Jet 3.0 or later, you can't complete the example in this exercise.

 
< previous page page_335 next page >

If you like this book, buy it!